package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理",tags = "敏感词管理API")
public class AdSensitiveController {
    //将Service层注入到Controller层，从而可以调用Service层中的方法
    @Autowired
    private AdSensitiveService adSensitiveService;
    @PostMapping("/list")
    @ApiOperation(value = "敏感词分页列表查询")
    public ResponseResult findpage(@RequestBody SensitiveDto sensitiveDto){
        return adSensitiveService.findpage(sensitiveDto);

    }
    @PostMapping("/save")
    @ApiOperation(value = "敏感词添加")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive){
         return adSensitiveService.insert(adSensitive);
    }
    @PostMapping("/update")
    @ApiOperation(value = "敏感词修改")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.update(adSensitive);
    }
    @DeleteMapping("/del/{id}")
    @ApiOperation(value = "敏感词删除")
    public ResponseResult delete(@PathVariable Integer id){
        return adSensitiveService.delete(id);
    }
}
